#!/bin/bash
set -e

# Gather name of changed files
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0

make add-licenses
make format
make lint
make lint-markdown-fix
make lint-markdown

# Add changed files to stage again because make format can change these files
echo "$FILES" | xargs git add

exit 0